<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>

<html>
<head>
    <meta charset="utf-8">
    <title>软件概况信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdSoftwareViewTable" lay-filter="wQbdSoftwareViewTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdSoftwareViewHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="swvxzan,rjgk3_xzan" css="layui-btn layui-btn-sm fillBtn" event="add">
                <span>新增</span>
            </@f.a>
            <@f.a alias="swvscan,rjgk3_scan" css="layui-btn layui-btn-sm" event="delete">
                <span>删除</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <span>导出</span>
            </a>
            <@f.a alias="rjgk2_dran,rjgk3_dran" css="layui-btn layui-btn-sm" event="import">
                <span>导入</span>
            </@f.a>
<!--            <a class="layui-btn layui-btn-sm" lay-event="query">
                <span>查询</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="clears">
                <span>重置</span>
            </a>-->
            <@f.a alias="swvsban,rjgk3_sban" css="layui-btn layui-btn-sm" event="report">
                <span>上报</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="listStyle">
                <span>配置列</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdSoftwareViewQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <@SourceDept.dept css="layui-input filter-value" />
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">软件名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_softwareName_SL" placeholder="请输入"/>
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">所属型号</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_model_SL" css="layui-input filter-value" nodeKey="szxh" />
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">软件研发阶段</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_softwareDevelopmentStage_SL" css="layui-input filter-value" nodeKey="rjyzjd" />
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">软件类型</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_softwareType_S" css="layui-input filter-value" nodeKey="rjlx" />
                        </div>
                    </div>

                    <div class="qbdms-listForm">
                        <label class="layui-form-label">关键等级</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_criticalLevel_SL" css="layui-input filter-value" nodeKey="gjdj" />
                        </div>
                    </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont  data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdSoftwareViewRightToolsBar">

    {{# if('${currentUserId}'==d.createBy && (d.reportStatus==12 || d.reportStatus==14|| d.reportStatus==17|| d.reportStatus==4|| d.reportStatus==6|| d.reportStatus==9)){}}
    <a class="RightBtn" lay-event="edit">编辑</a>
    {{#  } }}
    <a class="RightBtn" lay-event="particulars">详情</a>
    {{# if('${currentUserId}'==d.createBy && (d.reportStatus==4 || d.reportStatus==12)){ }}
    <a class="RightBtn" lay-event="del">删除 </a>
    {{#  } }}


    <!--{{# if('${currentUserId}'==d.createBy && (d.reportStatus==12 || d.reportStatus==14|| d.reportStatus==17|| d.reportStatus==4|| d.reportStatus==6|| d.reportStatus==9)){}}
    <@f.a alias="bjktan" css="RightBtn" event="edit">编辑</@f.a>
    &lt;!&ndash;<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>&ndash;&gt;
    {{#  } }}
    <@f.a alias="ktxqan" css="RightBtn" event="particulars">详情</@f.a>
    &lt;!&ndash;<a class="layui-btn layui-btn-xs" lay-event="particulars">详情</a>&ndash;&gt;
    {{# if('${currentUserId}'==d.createBy && (d.reportStatus==4 || d.reportStatus==12)){}}
    <@f.a alias="ktscan" css="RightBtn" event="del">删除</@f.a>
    &lt;!&ndash;<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>&ndash;&gt;
    {{#  } }}-->

</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table','form', 'common','publicMethods','jquery','layer'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        common.tableSort('wQbdSoftwareViewTable');

        var tableH=publicMethods.tabHeight();
        //
        var cols = '${cols}';
        //第一个实例
        window.tableInstace = function(tcols){
            if(tcols){
                cols = tcols;
            }
            if(cols){
                cols = JSON.parse(cols,function(k,v){
                    if(v.indexOf && v.indexOf('function') > -1){
                        return eval("(function(){return "+v+" })()")
                    }
                    return v;
                })
            }

            var showSta={field: 'reportStatusStr', title: '状态',sort:false, sortname: 'report_status',hide:false,minWidth:'150',templet: function(d){
                    return common.stateType(d);
                }};
            var source={field: 'filldept', title: '数据来源单位',sort:false, sortname: 'filldept',minWidth:'200'};
            if('${currentSystemLevel}'=='GROUPLEVEL'){
                showSta={field: 'reportStatusStr', title: '状态',sort:false, sortname: 'report_status',hide:true,minWidth:'150',templet: function(d){
                        return common.stateType(d);
                    }};
                source={field: 'filldeptHospital', title: '数据来源单位',sort:false, sortname: 'filldepthospital',minWidth:'200'};
            }

            window.tableInstace.initCols =[ //初始化的表头， 这里替换成自己的初始化表头json
                {type: 'checkbox', fixed: 'left'},{field: 'sn', type: 'numbers', title: '序号', fixed: 'left',hide:false,minWidth:'150'}
                ,source
                ,{field: 'softwareName', title: '软件名称',sort:false, sortname: 'software_name',hide:false,minWidth:'150'}
                ,{field: 'model', title: '所属型号',sort:false, sortname: 'model',hide:false,minWidth:'150'}
                ,{field: 'softwareDevelopmentStage', title: '软件研发阶段',sort:false, sortname: 'software_development_stage',hide:false,minWidth:'150'}
                ,{field: 'softwareType', title: '软件类型',sort:false, sortname: 'software_type',hide:false,minWidth:'150'}
                ,{field: 'criticalLevel', title: '关键等级',sort:false, sortname: 'critical_level',hide:false,minWidth:'150'}
                ,showSta
                ,{field: 'statisticalPeriod', title: '统计期',sort:true, sortname: 'statistical_period',templet: function (d) {
                        return publicMethods.timeData(d.statisticalPeriod,4);
                    },hide:true,minWidth:'150'}
                ,{field: 'productCode', title: '产品代号',sort:false, sortname: 'product_code',hide:true,minWidth:'150'}
                ,{field: 'softwareVersion', title: '软件版本',sort:false, sortname: 'software_version',hide:true,minWidth:'150'}
                ,{field: 'developmentUnit', title: '研制单位',sort:false, sortname: 'development_unit',hide:true,minWidth:'150'}
                ,{field: 'evaluationUnit', title: '测评单位',sort:false, sortname: 'evaluation_unit',hide:true,minWidth:'150'}
                ,{field: 'typesEvaluationItems', title: '测评项目类型',sort:false, sortname: 'types_evaluation_items',hide:true,minWidth:'150'}
                ,{field: 'programingLanguage', title: '编程语言',sort:false, sortname: 'programing_language',hide:true,minWidth:'150'}
                ,{field: 'operatingEnvironment', title: '运行环境',sort:false, sortname: 'operating_environment',hide:true,minWidth:'150'}

                ,{
                    fixed: 'right',
                    title: '管理',
                    width:180,
                    toolbar: '#wQbdSoftwareViewRightToolsBar'
                }
            ];

            window.tableInstace.tRender =table.render({
                elem: '#wQbdSoftwareViewTable'
                ,height:tableH
                ,url: serverPath.qbdmsPath + '/qbdms/wQbdSoftwareView/list'
                ,page: publicMethods.pageFun() //开启分页
                ,limit: 20
                ,toolbar: '#wQbdSoftwareViewHeaderToolsBar'
                ,method: 'post'
                ,defaultToolbar: ['']
                ,autoSort: false //是否排序
                ,cols: [cols?cols:window.tableInstace.initCols]
                ,done:function (d) {
                    common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
                }
            });
        };
        window.tableInstace(cols);
        //

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdSoftwareViewTable',true);

        dateReflash()
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
            publicMethods.reflashDate({startName:'.start_time3',endName:'.end_time3'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdSoftwareViewTable","wQbdSoftwareViewQueryForm",{where:{}},isClear);
            var xhmcList = eval('${xhmcList}'); //所属型号
            common.initDicData("Q_model_SL", xhmcList);
        }

        table.on('toolbar(wQbdSoftwareViewTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            var layerH=publicMethods.layHeight('.listBody');
            switch (obj.event) {
                case 'add':
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdSoftwareView/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                function open(url , param){
                    var curUrl = url;
                    layer.open({
                        type: 2,
                        area: ['700px', '520px'],
                        title: ['自定义导出', 'font-size:14px;'],
                        content: serverPath.qbdmsPath + '/qbdms/wQbdSoftwareView/view/export',
                        btnAlign: 'c',
                        skin: 'qbdms-layerFormBtn',
                        btn: ['确定', '取消'],
                        yes: function(index, layero){
                            url = curUrl;
                            var iframeWin = window["layui-layer-iframe" + index];
                            var data = iframeWin.getData();
                            if(data){
                                url = url + "?data=" + JSON.stringify(data) + param;
                                window.location.href = encodeURI(url)
                            }
                        }
                    });
                }
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdSoftwareView/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdSoftwareViewQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url , param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = serverPath.qbdmsPath + '/qbdms/wQbdSoftwareView/exportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdSoftwareViewTable',"/qbdms/wQbdSoftwareView/importData",true,"/importTemplates/软件概况.xlsx");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdSoftwareViewTable');
                    dateReflash();
                    form.render();
                    break;
                case "report":
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    //业务表名,勾选数据主键,流程key,table标签lay-filter属性值,form标签lay-filter属性值,是否允许重复上报,页面所在包名,流程定义id
                    common.report("w_qbd_software_view"
                        ,array
                        ,"plantToHospital"
                        ,"wQbdSoftwareViewTable"
                        ,"wQbdSoftwareViewQueryForm"
                        ,false
                        ,"wQbdSoftwareView"
                        ,"plantToHospital:1:72d05d40362249118c5453aa60c6da90");
                    dateReflash();
                    break;
                case "listStyle":
                    layer.open({
                        type: 2,
                        area: ['80%', layerH],
                        skin: 'qbdms-layerFormBtn',
                        title: ['新增列表样式', 'font-size:14px;'],
                        content: __ctx + '/qbdms/wCustomColumns/view/list',
                        success:function (layero, index) {
                            publicMethods.tipsAuto(layero.find('.layui-layer-setwin'),'点击这里关闭弹框哦',2000)
                        }
                    });
                    break;
            };
        });

        table.on('tool(wQbdSoftwareViewTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdSoftwareView/view/add?id="+data.id;
                    break;
                case "particulars":
                    window.location.href = serverPath.qbdmsPath + "/qbdms/wQbdSoftwareView/view/particulars?id="+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });
        table.on('sort()', function(obj){
            reflashQuery(false);
            dateReflash();
        });
        function delFun(data,id) {
            if (data.length === 0) {
                layer.msg('请先选择一行数据!');
            } else {
                var datatype;
                if("HOSPITALLEVEL"=="${currentSystemLevel}"){
                    datatype=2;
                }
                if("PLANTLEVEL"=="${currentSystemLevel}"){
                    datatype=1;
                }
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: serverPath.qbdmsPath + "/qbdms/wQbdSoftwareView/del",
                        type: "post",
                        data: {id:id,datatype:datatype},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            dateReflash();
            reflashQuery(true);
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdSoftwareViewTable");



        // //初始化数据字典
        var xhmcList = eval('${xhmcList}'); //所属型号
        common.initDicData("Q_model_SL", xhmcList);
        // var rjyzjdList = eval('${rjyzjdList}'); //软件研发阶段
        // common.initDicData("Q_softwareDevelopmentStage_SL", rjyzjdList);
        // var rjlxList = eval('${rjlxList}'); //软件类型
        // common.initDicData("Q_softwareType_SL", rjlxList);
        // var gjdjList = eval('${gjdjList}'); //关键等级
        // common.initDicData("Q_criticalLevel_SL", gjdjList);
        // var cpxmlxList = eval('${cpxmlxList}'); //测评项目类型
        // common.initDicData("Q_typesEvaluationItems_SL", cpxmlxList);
        // var originOrgList = eval('${originOrgList}'); //数据来源单位
        // common.initDicData("Q_filldept_SL", originOrgList);



    });
</script>
</body>
</html>